package view.model;

import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;


/**
 * @Author: Lin Hongwei
 * @LastEditors: Lin Hongwei
 * @email: 1365755396@qq.com
 * @CSDN: https://blog.csdn.net/weixin_45429409
 * @Description: 定义用户身份下拉框显示模块
 *
 */
public class UserTypeComboBoxModel implements ComboBoxModel<Object>{
	String[] typeList  = {"学生","老师","其他"};
	String type;
	/**
	 * @ 返回所选选项
	 */
	@Override
	public Object getSelectedItem() {
		// TODO Auto-generated method stub
		if(typeList!=null)return type;
		return null;
	}
	
	/**
	 * @ 设置所选项目
	 */
	@Override
	public void setSelectedItem(Object arg0) {
		System.out.println("设置选项---"+arg0);
		// TODO Auto-generated method stub
		type = (String) arg0;
	}
	
	

	@Override
	public int getSize() {
		// TODO Auto-generated method stub
		return typeList.length;
	}
	
	
	/**
	 * @ 获取到对应位置的元素
	 */
	@Override
	public Object getElementAt(int index) {
		// TODO Auto-generated method stub
		return typeList[index];
	}

	/**
	 * @ 事件监听
	 */
	@Override
	public void addListDataListener(ListDataListener arg0) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void removeListDataListener(ListDataListener arg0) {
		// TODO Auto-generated method stub
		
	}
	

}

